home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: How do I modify a character string that's declared as an array of char?
- Date: 26 Feb 1996 03:37:54 GMT
- Organization: Los Alamos National Laboratory
- Distribution: world
- Message-ID: <TANMOY.96Feb25203754@qcd.lanl.gov>
- References: <4gj2nl$840@mirzam.usc.edu> <4gqo63$2pr@newshost.cyberramp.net>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: sinan@cyberramp.net's message of 25 Feb 1996 22:34:43 GMT
-
- In article <4gqo63$2pr@newshost.cyberramp.net>
- sinan@cyberramp.net (John Noland) writes:
-
- JN: > char mydata[50];
- JN: >
- JN: > strcpy(mydata,"test string");
- JN: > myfunction(&mydata);
- JN: ^
- JN: Dereferencing mydata isn't necessary. mydata is a pointer to the first
- JN: character of your array, so what you're really doing is passing a pointer
- JN: to that pointer.
-
- Wrong. mydata is an array that usually decays to a pointer to the
- first character. One place where it does not decay is when it is the
- operand of &. &mydata is a pointer to the entire array. Read the FAQ
- for more details.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-